﻿using Bouyei.GeoCore.Geometries;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bouyei.GeoCore.GeoParsers.GeoPackage
{
    public class GeometryReader:BaseBytes
    {
        public GeometryReader(byte[] buffer,int offset=0)
            :base(buffer,offset)
        {

        }

        public Geometry Reader()
        {
            var header = GeoPackageHeader.Read(Buffer, Offset);
            Wkb.GeometryReader reader = new Wkb.GeometryReader(Buffer, Offset + header.HeaderLength+1,header.byteOrder);
            var geo= reader.Reader();

            geo.Ordinates = header.Ordinates;
            geo.SRID = header.SRID;

            return geo;
        }
    }
}
